package cn.stylefeng.roses.kernel.saas.request;

import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
import cn.stylefeng.roses.kernel.scanner.api.annotation.field.ChineseDescription;
import cn.stylefeng.roses.kernel.validator.api.validators.unique.TableUniqueValue;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;

/**
 * 租户请求实体类
 *
 * @author luojie
 * @date 2021/2/5 10:47
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SysTenantRequest extends BaseRequest implements Serializable {

    private static final long serialVersionUID = -6575806184583206340L;

    /**
     * 主键
     */
    @ChineseDescription("租户表主键")
    private Long tenantId;

    /**
     * 公司名称
     */
    @NotBlank(message = "公司名称 为空，请检查 companyName 参数！", groups = {add.class, edit.class, checkCompanyName.class})
    @ChineseDescription("公司名称")
    @TableUniqueValue(
            message = "公司名称存在重复",
            groups = {add.class, edit.class},
            tableName = "sys_tenant",
            columnName = "company_name",
            idFieldName = "tenant_id",
            excludeLogicDeleteItems = true)
    private String companyName;

    /**
     * 公司地址
     */
    @ChineseDescription("公司地址")
    private String companyAddress;

    /**
     * 公司logo
     */
    @ChineseDescription("公司logo")
    private Long companyLogo;

    /**
     * 统一社会信用代码
     */
    @ChineseDescription("统一社会信用代码")
    private String licenceNumber;

    /**
     * 注册邮箱
     */
    @Email(message = "注册邮箱格式错误，请重新输入", groups = {add.class, edit.class, sendEmailVerifyCode.class})
    @ChineseDescription("注册邮箱")
    @TableUniqueValue(
            message = "注册邮箱存在重复",
            groups = {add.class, edit.class},
            tableName = "sys_tenant",
            columnName = "email",
            idFieldName = "tenant_id",
            excludeLogicDeleteItems = true)
    private String email;

    /**
     * 密码
     */
    @NotBlank(message = "密码 为空，请检查 password 参数！", groups = {add.class})
    @ChineseDescription("密码")
    private String password;

    /**
     * 安全手机(注册时的手机号)
     */
    @NotBlank(message = "安全手机 为空，请检查 safePhone 参数！", groups = {add.class, edit.class})
    @ChineseDescription("安全手机(注册时的手机号)")
    @TableUniqueValue(
            message = "手机号已注册，请更换手机",
            groups = {add.class, edit.class},
            tableName = "sys_tenant",
            columnName = "safe_phone",
            idFieldName = "tenant_id",
            excludeLogicDeleteItems = true)
    private String safePhone;

    /**
     * 检查企业名称是否存在
     */
    public @interface checkCompanyName {

    }

    /**
     * 发送邮件验证码
     */
    public @interface sendEmailVerifyCode {

    }

}
